package com.qwt.part_time_api.service.impl;

import com.qwt.part_time_api.mapper.RoleMapper;
import com.qwt.part_time_api.pojo.Role;
import com.qwt.part_time_api.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 君子慎独
 * @create 2022/1/17 0017 22:50
 */
@Service
@Slf4j
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public String findRoleNameByAccount(String account) {
        log.info("根据账号查询角色");
        return roleMapper.findRoleNameByAccount(account);
    }

    @Override
    public List<Role> findAllByApiUrl(String url) {
        log.info("根据当前访问路径查询角色");
        return roleMapper.findAllByApiUrl(url);
    }

    @Override
    public void saveUserRole(Long rid, Long uid) {
        log.info("给将用户添加角色");
        roleMapper.saveUserRole(rid, uid);
    }
}
